﻿//-----------------------------------------------
// RedditSharp (Reddit#)
//
// Copyright (c) 2011 - 2012
// - Angelo Geels <angelo@angelog.nl>
//-----------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RedditSharp
{
    public class RedditThing
    {
        /// <summary>
        /// The ID of the thing.
        /// </summary>
        public string ID;

        /// <summary>
        /// The full ID of the thing.
        /// </summary>
        public string FullID;

        public string Subreddit;

        public int MyScore;
        public int Score;
        public int Upvotes;
        public int Downvotes;
        public int Comments;

        /// <summary>
        /// Unvote the thing.
        /// </summary>
        public void Unvote()
        {
            Reddit.Upload("api/vote", "id=" + this.FullID + "&dir=0");
            this.MyScore = 0;
        }

        /// <summary>
        /// Upvote the thing.
        /// </summary>
        public void Upvote()
        {
            Reddit.Upload("api/vote", "id=" + this.FullID + "&dir=1");
            this.MyScore = 1;
        }

        /// <summary>
        /// Downvote the thing.
        /// </summary>
        public void Downvote()
        {
            Reddit.Upload("api/vote", "id=" + this.FullID + "&dir=-1");
            this.MyScore = -1;
        }

        /// <summary>
        /// Replies to this thing with the given text.
        /// </summary>
        /// <param name="Text">The text</param>
        public void Reply(string Text)
        {
            Reddit.Upload("api/comment", "parent=" + this.FullID + "&text=" + Uri.EscapeDataString(Text));
        }
    }
}
